package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.User;
import com.zr.service.FunctionServicecy;
import com.zr.serviceImpl.FunctionServiceImplcy;

import net.sf.json.JSONArray;
public class ShowFunctionControllercy extends HttpServlet{
	//创建功能展示对象
	FunctionServicecy  fn = new FunctionServiceImplcy();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//设置编码格式
	resp.setCharacterEncoding("utf8");
	//创建数据回写对象
	PrintWriter pw1=resp.getWriter();
	//设置父节点
	HttpSession session=req.getSession();
	User u=(User)session.getAttribute("User");
	int uid=u.getUid();
	int pid=fn.findPidByUid(uid);
	JSONArray j=fn.getFunction(pid);
	pw1.write(j.toString());
	}
}
